<?php

/**
 * User model
 *
 * @package       AgencyCMS
 * @subpackage    AgencyCMS.users
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
 */
/**
 * AgencyUser
 */
class AgencyUser extends AppModel {

    /**
     * @var string Class name
     */
    var $name = 'AgencyUser';

    /**
     * @var array Behaviors
     */
    var $actsAs = array(
        'SoftDeletable'
    ); 

    /**
     * @var array Validation rules
     */
    var $validate = array(
        'username' => array(
            'unique' => array(
                'rule' => 'isUnique',
                'message' => 'This username is already in use'
            ),
            'valid' => array(
                'rule' => '/^[a-z0-9_]+$/i',
                'message' => 'Usernames may only contain letters, numbers and underscores'
            )
        ),
        'email' => array(
            'rule' => 'email',
            'message' => 'A valid email address is required'
        ),
        'new_password' => array(
            'rule' =>'notEmpty',
            'message' => 'Passwords cannot be blank'
        ),
        'confirm_password' => array(
            'rule' => array('identicalFieldValues', 'new_password'),
            'message' => 'Please retype the new password exactly'
        )
    );

}